package cn.edu.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 1、加载驱动
 * 2、建立连接
 */
public class JdbcDemo02 {
    static String url = "jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true";
    static String user = "root";
    static String password = "root";
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            System.out.println("驱动加载成功~~~");
            Connection conn = DriverManager.getConnection(url,user,password);
            System.out.println(conn);
            System.out.println("与数据库建立好连接了~~");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
